﻿using System;
using System.Collections;
using System.Data;
using System.Data.SqlClient;
using System.Text;
using System.Web;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using AnyOffice.Components;
using AnyOffice.DAL;
using AnyOffice.BIZ;


namespace AnyOffice.general.notify.show
{
    public partial class read_notify : ModulePage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            int notifyId = (Request.QueryString["notify_id"] == null) ? 0 : int.Parse(Request.QueryString["notify_id"].ToString());
            DataTable table = new NotifyDao().SelectByNotifyId(base.Conn, notifyId, base.User.Identity.Name);
            if (table.Rows.Count == 0)
            {
                this.pnlMain.Visible = false;
                this.litMessage.Text = base.ShowPromptClose("无文件通知记录");
            }
            else
            {
                new ConfigManager();
                UserCache cache = new UserCache();
                bool flag = false;
                if ((!flag && (table.Rows[0]["ToId"] != DBNull.Value)) && (table.Rows[0]["ToId"].ToString() == "ALL_DEPT"))
                {
                    flag = true;
                }
                if ((!flag && (table.Rows[0]["ToId"] != DBNull.Value)) && (string.Format(",{0},", table.Rows[0]["ToId"].ToString()).IndexOf(string.Format(",{0},", cache.DeptId.ToString())) >= 0))
                {
                    flag = true;
                }
                if ((!flag && (table.Rows[0]["ToPriv"] != DBNull.Value)) && (string.Format(",{0},", table.Rows[0]["ToPriv"].ToString()).IndexOf(string.Format(",{0},", cache.PrivId.ToString())) >= 0))
                {
                    flag = true;
                }
                if ((!flag && (table.Rows[0]["ToUser"] != DBNull.Value)) && (string.Format(",{0},", table.Rows[0]["ToUser"].ToString()).IndexOf(string.Format(",{0},", base.User.Identity.Name)) >= 0))
                {
                    flag = true;
                }
                if (!flag)
                {
                    this.pnlMain.Visible = false;
                    this.litMessage.Text = base.ShowPromptClose("无文件通知记录");
                }
                else
                {
                    this.litSubject.Text = table.Rows[0]["Subject"].ToString();
                    this.litTypeName.Text = table.Rows[0]["TypeName"].ToString();
                    this.litUserName.Text = "<u title=\"部门：" + table.Rows[0]["DeptName"].ToString() + "\" style=\"CURSOR:hand\">" + table.Rows[0]["UserName"].ToString() + "</u>";
                    this.litSendTime.Text = table.Rows[0]["SendTime"].ToString();
                    if (table.Rows[0]["Content"] != DBNull.Value)
                    {
                        this.litContent.Text = table.Rows[0]["Content"].ToString();
                    }
                    if (table.Rows[0]["AttachmentId"] != DBNull.Value)
                    {
                        string attachmentId = table.Rows[0]["AttachmentId"].ToString();
                        if ((this.litAttachment.Text = AttachmentBiz.Display(base.Conn, attachmentId)) != string.Empty)
                        {
                            this.pnlAttachment.Visible = true;
                        }
                        else
                        {
                            this.litAttachment.Text = "无";
                        }
                    }
                }
            }
        } 

    }
}
